/**
 * 业务接口 -> 原料采购,物资管理
 */
import { httpJ } from '../conf/index-json'
import { baseURL} from '../conf/index'
import qs from 'qs'
import store from '@/store'

/*************************************** 原料采购模块/采购模式API *******************************************/

// 报表审核 - 采购计划查看
export const postPurchasingPlans = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 审核列表
export const postPurchasingPlansAuditLog = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/audit/log`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 审核(驳回/通过)
export const postPurchasingPlansAudit = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/audit`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 取消审核
export const postPurchasingPlansCancel = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/cancel`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 未提交列表
export const postPurchasingPlansNone = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/none`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 聚合列表
export const postPurchasingPlansDetail = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/detail`, (params)).then(res => res.data)
}

// 报表审核 - 采购计划查看 - 计算食物定量分析
export const postPurchasingPlansFoodStatistic = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/purchasing/plans/foodStatistic`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 入库记录
export const postInRecords = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/in/records`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 入库记录详情
export const postRecordsDetail = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/in/records/detail`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 出库记录
export const postOutRecords = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/out/records`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 出库记录详情
export const postOutRecordsDetail = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/out/records/detail`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 消耗汇总
export const postRecordsConsume = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/consume/records`, (params)).then(res => res.data)
}

// 数据查询 - 物资管理查询 - 消耗汇总详情
export const postRecordsConsumeDetail = (params = {}) => {
    return httpJ.post(`${baseURL}/api/organ/goods/consume/records/detail`, (params)).then(res => res.data)
}

/*************************************** 页面接口模板API *******************************************/
// GET 请求
export const getTopLevel = (params = {}) => {
    return httpJ.get(`${baseURL}/head/get_info`, { params }).then(res => res.data)
}

// POST 请求
export const modifyTopLevelInfo = (params = {}) => {
    return httpJ.post(`${baseURL}/head/modify`, qs.stringify(params)).then(res => res.data)
}

// 导入
export const uploadRecipe = (params = {}) => { // 文件上传
    return httpJ.post(`${baseURL}/meal/import_excel`, params, {
        headers: { 'Content-Type': 'multipart/form-data' }
    }).then(res => res.data)
}
// 导出模板如下
export const exportUserDinnerListForMealTime = `${baseURL}/meal_record/export_segment_list?token=${store.state.vuex_user.token}`
